package com.atguigu.paymentdemo.util;

import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.HashMap;
import java.util.Map;

public class PaymentRequest {
    public static void main(String[] args) {
        // 创建参数Map
        Map<String, Object> params = new HashMap<>();
        params.put("mchKey", "10008");
        params.put("mchOrderNo", "order_0000000001");
        params.put("serialOrderNo", "PAY0WECHAT111565MBJlhjVt");
        params.put("nonce", "BzPdZr#WfSImpHjp");
        params.put("payStatus", "SUCCESS");
        params.put("amount", 20000);
        params.put("realAmount", 20000);
        params.put("payTime", "2021/10/31 17:00:27"); // 可选字段，根据需求决定是否添加
        params.put("mchUserId", "user_0001"); // 可选字段，根据需求决定是否添加
        params.put("attach", "name=test;age=18"); // 可选字段，根据需求决定是否添加
        params.put("errorMsg", "管理员补单，测试单已清账"); // 可选字段，根据需求决定是否添加
        params.put("timestamp", 1636972859708L);
        params.put("sign", "acb4a97c3eedc80c0a1522c6a6522667");

        // 将Map转换为JSON字符串
        ObjectMapper objectMapper = new ObjectMapper();
        try {
            String jsonString = objectMapper.writeValueAsString(params);
            System.out.println(jsonString);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}